from selenium import webdriver
from bs4 import  BeautifulSoup
class Weber:
    def __init__(self, url):
        options = webdriver.FirefoxOptions()
        options.add_argument('-headless')
        # self.driver = webdriver.firefox("points/geckodriver.exe", options=options)
        self.driver = webdriver.Firefox(options=options)
        print("driver Opened")
        # self.driver = webdriver.Firefox()
        self.driver.get(url)
        print("URL Getted")
    def get_rank_html(self):
        # rank_clk = self.driver.find_element_by_xpath("//a[@href='#rank']")
        table = self.driver.find_element_by_id("contest-rank-table")
        bs = BeautifulSoup(table.get_attribute("outerHTML"),'lxml')
        res = bs.find('tbody')
        with open('tmp.html', "w", encoding="utf-8") as f:
            print(res, file=f)
        return res
        

# T = Weber("https://vjudge.net/contest/363301#rank")
# T.get_rank_html()
# T.driver.quit()
# with open("tmp.html", "w") as f:
#     f.write(T.get_rank_html())

# T = Weber("http://cn.bing.com/")
